<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 2020-06-10
 * Time: 11:35
 */

namespace app\api\controller\v1;


use app\api\controller\BaseController;
use app\api\model\MemberCost;
use app\api\service\member\MemberOrderSer;
use app\api\service\member\MemberSer;
use app\api\validate\member\CheckMember;
use think\facade\Request;

class Member extends BaseController
{
    protected $beforeActionList = [
        'checkPrimaryScope' => ['only' => 'getCostList']
    ];

    /**
     * 创建或者更新用户信息
     */
    public function createUpdateMember()
    {
        (new CheckMember())->goCheck();
        $post = Request::post();
        $memberSer = new MemberSer($post);
        return $memberSer->get();
    }


    /**
     * 获取会员费
     */
    public function getCostList()
    {
        return MemberCost::order('id asc')->select()->toArray();
    }

    /**
     * 支付会员费
     * return 支付number
     */
    public function placeOrder($member_cost_id)
    {
        $memberOrder = new MemberOrderSer($member_cost_id);
        return $memberOrder->place();
    }
}